#include "udpclientthread.h"

UdpClientThread::UdpClientThread(QObject *parent, quint16 port) : QThread(parent)
{
    this->port = port;
    clientSocket = new QUdpSocket;

    connect(this, &UdpClientThread::sendMessageSignal, this, &UdpClientThread::sendMessageSlot);
}

/*
void UdpClientThread::run()
{
    exec();
}
*/

void UdpClientThread::sendMessageSlot(const QByteArray &message)
{
    if (clientSocket) {
        clientSocket->writeDatagram(message, QHostAddress::LocalHost, port);
        qDebug() << "Sent:" << QString(message);
    }
}
